package com.todo.content.application.handler.changeStatus;

import com.todo.content.common.enums.ContentStatusEnum;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/12/12 19:32
 * @description
 */
@Component
public class ContentStatusFactory {

    @Autowired
    private List<AbstractContentStatusHandler> handlerList;


    public AbstractContentStatusHandler getHandle(ContentStatusEnum statusEnum){
        if (CollectionUtils.isEmpty(handlerList)){
            return null;
        }
        for (AbstractContentStatusHandler handler : handlerList){
            if (handler.getDealStatus().equals(statusEnum)){
                return handler;
            }
        }
        return null;
    }
}
